﻿<?xml version="1.0" encoding="utf-8" ?>
<Recipe Name="CreateVSCustomTool" xmlns="http://schemas.microsoft.com/pag/gax-core"
                               xmlns:xi="http://www.w3.org/2001/XInclude" Bound="false">
  <DocumentationLinks>
    <Link Kind="Documentation" Caption="Implementing Single File Generators" Url="ms-help://MS.VSCC.v90/MS.VSIPCC.v90/MS.VSSDK.v90/dv_vsintegration/html/fe9ef6b6-4690-4c2c-872c-301c980d17fe.htm" />
  </DocumentationLinks>
  <xi:include href="../Common/CommonTypeAliases.xml"
				xpointer="xmlns(gax=http://schemas.microsoft.com/pag/gax-core) xpointer(/gax:Types)" />
  <Caption>VS Custom Tool</Caption>
  <Description>VS Custom Tool</Description>
  <HostData>
    <Icon ID="212" />
    <CommandBar Menu="VSSDKAssistProjectCreate"/>
  </HostData>
  <Arguments>
    <xi:include href="../Common/CommonArguments.xml"
					  xpointer="xmlns(gax=http://schemas.microsoft.com/pag/gax-core) xpointer(/gax:Arguments/gax:Argument)" />
    <Argument Name="VSPackageProject" Type="EnvDTE.Project, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Required="true">
      <ValueProvider Type="VSSDKAssist.Assets.ValueProviders.VisualStudio.CurrentlySelectedProjectValueProvider, VSSDKAssist.Assets"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="VSPackageProjectNamespace" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="$(VSPackageProject.Properties.Item('DefaultNamespace').Value.ToString())"
                     Stage="OnBeginRecipe">
      </ValueProvider>
    </Argument>
    <Argument Name="DestinationFolder" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="CustomTools"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="CommonDestinationFolder" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="Common"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="CommonCodeGeneratorNamespace" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="$(VSPackageProjectNamespace).$(CommonDestinationFolder)"
                     Stage="OnBeginRecipe">
        <MonitorArgument Name="VSPackageProjectNamespace"/>
        <MonitorArgument Name="CommonDestinationFolder"/>
      </ValueProvider>
    </Argument>
    <Argument Name="CodeGeneratorNamespace" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="$(VSPackageProjectNamespace).$(DestinationFolder)"
                     Stage="OnBeginRecipe">
        <MonitorArgument Name="VSPackageProjectNamespace"/>
        <MonitorArgument Name="DestinationFolder"/>
      </ValueProvider>
    </Argument>
    <Argument Name="CodeGeneratorGuid" Type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Required="true">
      <ValueProvider Type="VSSDKAssist.Assets.ValueProviders.Framework.GuidValueProvider, VSSDKAssist.Assets"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="CodeGeneratorName" Required="true"/>
    <Argument Name="CodeGeneratorDescription" Required="true"/>
    <Argument Name="LanguageExtension" Required="true">
      <ValueProvider Type="VSSDKAssist.Assets.ValueProviders.VisualStudio.CurrentlySelectedProjectLanguageValueProvider, VSSDKAssist.Assets"
               Stage="OnBeginRecipe">
      </ValueProvider>
    </Argument>
    <Argument Name="CodeGeneratorFileName">
      <ValueProvider Type="Evaluator"
                     Expression="$(CodeGeneratorName).$(LanguageExtension)"
                     Stage="OnBeginRecipe">
        <MonitorArgument Name="CodeGeneratorName"/>
      </ValueProvider>
    </Argument>
    <Argument Name="AssociatedFileExtension" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression=".myExtension"
                     Stage="OnBeginRecipe">
      </ValueProvider>      
    </Argument>
    <Argument Name="BaseCodeGeneratorFileName" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="BaseCodeGenerator.$(LanguageExtension)"
                     Stage="OnBeginRecipe">
      </ValueProvider>
    </Argument>
    <Argument Name="BaseCodeGeneratorWithSiteFileName" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="BaseCodeGeneratorWithSite.$(LanguageExtension)"
                     Stage="OnBeginRecipe">
      </ValueProvider>
    </Argument>
    <Argument Name="BaseCustomToolFileName" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="BaseCustomTool.$(LanguageExtension)"
                     Stage="OnBeginRecipe">
      </ValueProvider>
    </Argument>
    <Argument Name="CodeGeneratorRegistrationAttributeFileName" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="CodeGeneratorRegistrationAttribute.$(LanguageExtension)"
                     Stage="OnBeginRecipe">
      </ValueProvider>
    </Argument>
    <Argument Name="GeneratesDesignTimeSource" Type="System.Boolean" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="true"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="GeneratesSharedDesignTimeSource" Type="System.Boolean" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="false"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="VCSProjectContext" Type="System.Boolean" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="true"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="VBProjectContext" Type="System.Boolean" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="false"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="VJSProjectContext" Type="System.Boolean" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="false"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="BaseCodeGeneratorTT">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.TTPathValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"
                     SubPath="VSCustomTool"
                     TTFile="BaseCodeGenerator.tt">
      </ValueProvider>
    </Argument>
    <Argument Name="BaseCodeGeneratorWithSiteTT">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.TTPathValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"
                     SubPath="VSCustomTool"
                     TTFile="BaseCodeGeneratorWithSite.tt">
      </ValueProvider>
    </Argument>
    <Argument Name="CodeGeneratorRegistrationAttributeTT">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.TTPathValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"
                     SubPath="VSCustomTool"
                     TTFile="CodeGeneratorRegistrationAttribute.tt">
      </ValueProvider>
    </Argument>
    <Argument Name="CodeGeneratorTT">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.TTPathValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"
                     SubPath="VSCustomTool"
                     TTFile="CodeGenerator.tt">
      </ValueProvider>
    </Argument>
    <Argument Name="BaseCustomToolTT">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.TTPathValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"
                     SubPath="VSCustomTool"
                     TTFile="BaseCustomTool.tt">
      </ValueProvider>
    </Argument>
  </Arguments>
  <GatheringServiceData>
    <Wizard xmlns="http://schemas.microsoft.com/pag/gax-wizards" SchemaVersion="1.0">
      <Pages>
        <Page Type="VSSDKAssist.Recipes.CreateVSCustomTool.CreateVSCustomToolCP1, VSSDKAssist"
          Height="200" Width="510">
          <Title>Specify custom tool general properties</Title>
          <LinkTitle>Specify custom tool general properties</LinkTitle>
        </Page>
        <Page Type="VSSDKAssist.Recipes.CreateVSCustomTool.CreateVSCustomToolCP2, VSSDKAssist"
          Height="200" Width="510">
          <Title>Specify custom tool behavior</Title>
          <LinkTitle>Specify custom tool behavior</LinkTitle>
        </Page>
      </Pages>
    </Wizard>
  </GatheringServiceData>
  <Actions CoordinatorServiceType="VSSDKAssist.Recipes.Common.Coordinators.ExecutionProgressCoordinator, VSSDKAssist">
    <!-- Add a references-->
    <Action Name="AddReference1"
            Type="VSSDKAssist.Assets.Actions.VisualStudio.VisualStudio.AddProjectReferenceAction, VSSDKAssist.Assets"
            ReferencedAssembly="VSLangProj.dll"
            StatusMessage="Adding references"
            WriteMessageToOutputWindow="true">
      <Input Name="ReferringProject" RecipeArgument="VSPackageProject"/>
    </Action>
    <Action Name="AddReference2"
            Type="VSSDKAssist.Assets.Actions.VisualStudio.VisualStudio.AddProjectReferenceAction, VSSDKAssist.Assets"
            ReferencedAssembly="VSLangProj80.dll"
            StatusMessage="Adding references"
            WriteMessageToOutputWindow="true">
      <Input Name="ReferringProject" RecipeArgument="VSPackageProject"/>
    </Action>
    <Action Name="AddReference3"
            Type="VSSDKAssist.Assets.Actions.VisualStudio.VisualStudio.AddProjectReferenceAction, VSSDKAssist.Assets"
            ReferencedAssembly="EnvDTE.dll"
            StatusMessage="Adding references"
            WriteMessageToOutputWindow="true">
      <Input Name="ReferringProject" RecipeArgument="VSPackageProject"/>
    </Action>
    <Action Name="AddReference4"
            Type="VSSDKAssist.Assets.Actions.VisualStudio.VisualStudio.AddProjectReferenceAction, VSSDKAssist.Assets"
            ReferencedAssembly="EnvDTE80.dll"
            StatusMessage="Adding references"
            WriteMessageToOutputWindow="true">
      <Input Name="ReferringProject" RecipeArgument="VSPackageProject"/>
    </Action>
    <!--Create Folders-->
    <Action Name="GenerateCommonDestinationFolder"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddProjectFolderAction, VSSDKAssist.Assets"
          StatusMessage="Creating destination folders"
          WriteMessageToOutputWindow="true">
      <Input Name="FolderName" RecipeArgument="CommonDestinationFolder"/>
      <Output Name="FolderAdded" />
    </Action>
    <Action Name="GenerateDestinationFolder"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddProjectFolderAction, VSSDKAssist.Assets">
      <Input Name="FolderName" RecipeArgument="DestinationFolder"/>
      <Output Name="FolderAdded" />
    </Action>
    <!-- Add common classes if not exists-->
    <Action Name="GenerateBaseCodeGeneratorContent"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library"
          StatusMessage="Creating common classes"
          WriteMessageToOutputWindow="true">
      <Input Name="Template" RecipeArgument="BaseCodeGeneratorTT"/>
      <Input Name="CommonCodeGeneratorNamespace" RecipeArgument="CommonCodeGeneratorNamespace"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddBaseCodeGeneratorContent"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddItemFromStringToProjectItemAction, VSSDKAssist.Assets"
          Open="true">
      <Input Name="Content" ActionOutput="GenerateBaseCodeGeneratorContent.Content" />
      <Input Name="TargetFileName" RecipeArgument="BaseCodeGeneratorFileName"/>
      <Input Name="InputProjectItem" ActionOutput="GenerateCommonDestinationFolder.FolderAdded" />
    </Action>
    <Action Name="GenerateBaseCodeGeneratorWithSiteContent"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library">
      <Input Name="Template" RecipeArgument="BaseCodeGeneratorWithSiteTT"/>
      <Input Name="CommonCodeGeneratorNamespace" RecipeArgument="CommonCodeGeneratorNamespace"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddBaseCodeGeneratorWithSiteContent"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddItemFromStringToProjectItemAction, VSSDKAssist.Assets"
          Open="true">
      <Input Name="Content" ActionOutput="GenerateBaseCodeGeneratorWithSiteContent.Content" />
      <Input Name="TargetFileName" RecipeArgument="BaseCodeGeneratorWithSiteFileName"/>
      <Input Name="InputProjectItem" ActionOutput="GenerateCommonDestinationFolder.FolderAdded" />
    </Action>
    <Action Name="GenerateCodeGeneratorRegistrationAttributeContent"
      Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library">
      <Input Name="Template" RecipeArgument="CodeGeneratorRegistrationAttributeTT"/>
      <Input Name="CommonCodeGeneratorNamespace" RecipeArgument="CommonCodeGeneratorNamespace"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddCodeGeneratorRegistrationAttributeContent"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddItemFromStringToProjectItemAction, VSSDKAssist.Assets"
          Open="true">
      <Input Name="Content" ActionOutput="GenerateCodeGeneratorRegistrationAttributeContent.Content" />
      <Input Name="TargetFileName" RecipeArgument="CodeGeneratorRegistrationAttributeFileName"/>
      <Input Name="InputProjectItem" ActionOutput="GenerateCommonDestinationFolder.FolderAdded" />
    </Action>
    <Action Name="GenerateBaseCustomToolContent"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library">
      <Input Name="Template" RecipeArgument="BaseCustomToolTT"/>
      <Input Name="CommonCodeGeneratorNamespace" RecipeArgument="CommonCodeGeneratorNamespace"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddBaseCustomToolContent"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddItemFromStringToProjectItemAction, VSSDKAssist.Assets"
          Open="true">
      <Input Name="Content" ActionOutput="GenerateBaseCustomToolContent.Content" />
      <Input Name="TargetFileName" RecipeArgument="BaseCustomToolFileName"/>
      <Input Name="InputProjectItem" ActionOutput="GenerateCommonDestinationFolder.FolderAdded" />
    </Action>
    <!-- Add code generator class -->
    <Action Name="GenerateCodeGeneratorContent"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library"
          StatusMessage="Creating code generator class"
          WriteMessageToOutputWindow="true">
      <Input Name="Template" RecipeArgument="CodeGeneratorTT"/>
      <Input Name="CodeGeneratorNamespace" RecipeArgument="CodeGeneratorNamespace"/>
      <Input Name="CodeGeneratorGuid" RecipeArgument="CodeGeneratorGuid"/>
      <Input Name="CodeGeneratorName" RecipeArgument="CodeGeneratorName"/>
      <Input Name="GeneratesDesignTimeSource" RecipeArgument="GeneratesDesignTimeSource"/>
      <Input Name="GeneratesSharedDesignTimeSource" RecipeArgument="GeneratesSharedDesignTimeSource"/>
      <Input Name="VCSProjectContext" RecipeArgument="VCSProjectContext"/>
      <Input Name="VBProjectContext" RecipeArgument="VBProjectContext"/>
      <Input Name="VJSProjectContext" RecipeArgument="VJSProjectContext"/>
      <Input Name="CommonCodeGeneratorNamespace" RecipeArgument="CommonCodeGeneratorNamespace"/>
      <Input Name="CodeGeneratorDescription" RecipeArgument="CodeGeneratorDescription"/>
      <Input Name="AssociatedFileExtension" RecipeArgument="AssociatedFileExtension"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddCodeGeneratorContent"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddItemFromStringToProjectItemAction, VSSDKAssist.Assets"
          Open="true">
      <Input Name="Content" ActionOutput="GenerateCodeGeneratorContent.Content" />
      <Input Name="TargetFileName" RecipeArgument="CodeGeneratorFileName"/>
      <Input Name="InputProjectItem" ActionOutput="GenerateDestinationFolder.FolderAdded" />
    </Action>
  </Actions>
</Recipe>